package code15.io;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Homework02 {
	
	public static void main(String[] args) {
		test1();
	}

	public static void test1() {
		// 提示用户输入的 一行英文语句，将语句中英文单词首尾字母转换为大写，
		// 并以一行一个单词的形式保存到指定文件中
		// 例如: 输入 this is a bird -->
		// 文件内容如下:
		/* ThiS
		 * IS
		 * A
		 * BirD
		 */
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入一句英文:");
		String line = sc.nextLine();
		String[] arr = line.split(" ");
		
		try (
				PrintWriter pw = new PrintWriter("src/code15/io/word.txt");
				) {
			for (String str : arr) {
				char[] charArray = str.toCharArray();
				// 首
				charArray[0] = Character.toUpperCase(charArray[0]);
				// 尾
				charArray[charArray.length-1] = Character.toUpperCase(charArray[charArray.length-1]);
				
				pw.write(charArray);
				pw.println();
			}
			System.out.println("finish");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
	}
	
}
